#!/usr/bin/python
# -*- coding: utf-8 -*-
# @version        : 1.0
# @Create Time    : 2025/04/15 13:25
# @File           : camera.py
# @IDE            : PyCharm
# @desc           : pydantic 模型，用于数据库序列化操作

from pydantic import BaseModel, Field, ConfigDict
from core.data_types import DatetimeStr


class Camera(BaseModel):
    serial_number: str = Field(..., title="摄像头序列号，厂商所提供的全球唯一标识")
    model: str | None = Field(None, title="摄像头型号")
    ip_address: str = Field(..., title="摄像头IP地址")
    status: str = Field("offline", title="摄像头状态")
    last_active: DatetimeStr | None = Field(None, title="最后一次活动时间")
    room_id: int | None = Field(None, title="房间ID")


class CameraSimpleOut(Camera):
    model_config = ConfigDict(from_attributes=True)

    id: int = Field(..., title="编号")
    create_datetime: DatetimeStr = Field(..., title="创建时间")
    update_datetime: DatetimeStr = Field(..., title="更新时间")
